package com.cbtx.module.common.ui;

import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.cbtx.module.common.R;
import com.cbtx.module.common.bean.GoodsEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * @author : Lambert
 * date   : 2020/10/24 2:55 PM
 */
public class GoodsAdapter extends BaseQuickAdapter<GoodsEntity.DataBean.ListBean, BaseViewHolder> {

    int mWidth = 283;

    public GoodsAdapter(@Nullable List<GoodsEntity.DataBean.ListBean> data, int width) {
        super(R.layout.item_goods, data);
        mWidth = width;
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsEntity.DataBean.ListBean item) {

        ImageView mIvCover = helper.getView(R.id.mIvQRCode);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mIvCover.getLayoutParams();
        layoutParams.width = mWidth;
        layoutParams.height = mWidth;

        mIvCover.setLayoutParams(layoutParams);

        Glide.with(mContext)
                .load(item.coverImg)
                .error(R.drawable.ic_default_small)
                .placeholder(R.drawable.ic_default_small)
                .into(mIvCover);
    }
}
